package com.xiaoluo.a12_imageload22

import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import java.io.File
import java.net.HttpURLConnection
import java.net.URL

class MainActivity : AppCompatActivity() {

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_main)
    }

    fun getConnection(url: URL): HttpURLConnection? {
        var connection = url.openConnection() as HttpURLConnection
        connection.connectTimeout = 8000
        connection.readTimeout = 8000
        return connection
    }

    fun writeFile(httpURLConnection: HttpURLConnection, savePath: String, name: String) {
        var input = httpURLConnection.inputStream
        var saveFile = File(savePath)
        if (!saveFile.exists()) {
            saveFile.mkdirs()
        }
        var outputStream = null

    }

}
